package de.bht.netviz.traceroute.service;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Status Message Bean für Ausgaben eines Traceroute Laufs.
 * 
 * @author Marius Hentschel
 * @since  2012/11/08
 */
public class TraceRouteMessageServlet extends AbstractStatusMessageServlet {

   /**
    * Processes requests for both HTTP
    * <code>GET</code> and
    * <code>POST</code> methods.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   @Override
   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      try {
         /* TODO output your page here. You may use following sample code. */
         out.println("<hop num=\"1\">");
         out.println(  "<ip>141.64.64.185</ip>");
         out.println(  "<hostname>vfh185.beuth-hochschule.de</hostname>");         
         out.println(  "<time1>64</time1>");
         out.println(  "<time2>58</time2>");
         out.println(  "<time3>74</time3>");
         out.println(  "<coordinates><lat>51.1234</lat></lon>71.2345</lon></coordinates>");
         out.println("</hop>");
      } finally {         
         out.close();
      }
   }

}
